<?php
/**
 *
 * 功能说明：封禁IP规则模型。
 *
 **/
namespace Home\Model;
use Common\Model\BaseModel;
use Think\Model;
class IpModel extends BaseModel {
	protected $_validate = array(
		array('Ip','','要封禁的IP已经在黑名单中了',0,'unique',3),			//验证IP是否已经存在
		array('Ip','/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/i','请填写正确的IP地址',0,'regex'),
		//array('StartTime','/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/','请选择正确的日期',2,'regex',3),
		//array('EndTime','/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/','请选择正确的日期',2,'regex',3),
		array('Status','number','封禁值获取出错',0),
		array('Description','0,50','请将描述控制在50个字符以内',0,'length',3)
	);
	public function getIpList($keyword){
		if ($keyword!='') {
			$where['ip'] = $keyword;
			$count = $this->where($where)->count();			//总记录数
		}else {
			$count = $this->count();
		}
		$Page = new \Think\Page($count,25);// 实例化分页类 传入总记录数和每页显示的记录数
		$Page->setConfig('header','条记录');
		$Page->setConfig('prev','<img src="__IMAGE__/prev.gif" border="0" title="上一页" />');
		$Page->setConfig('next','<img src="__IMAGE__/next.gif" border="0" title="下一页" />');
		$Page->setConfig('first','<img src="__IMAGE__/first.gif" border="0" title="第一页" />');
		$Page->setConfig('last','<img src="__IMAGE__/last.gif" border="0" title="最后一页" />');
		$data['show'] = $Page->show();							//分页显示输出
		$data['volist'] = $this->alias('a')->join('LEFT JOIN __USER__ as b ON a.uid=b.id')->where($where)->order('dtime desc')->field('a.*,b.username')->limit($Page->firstRow.','.$Page->listRows)->select();
		$data['count']=$count;
		return $data;
	}
	
}
?>